<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
hello,world

<h1>title</h1>
</body>
<script>
    function Color(elem) {
        this.elem = elem;
        this.colors = ["red", "yellow", "green", "blue"];
        this.run = function () {
            setInterval(function () {
                let i = Math.floor(Math.random() * this.colors.length);
                console.log(this.colors[i])
                this.elem.style.backgroundColor = this.colors[i]
            }.bind(this), 1000)
        }
    }

    let obj = new Color(document.body)
    obj.run();

    let h1 = new Color(document.querySelector('h1'));
    h1.run();
</script>
</html>
